import config from "@/config";

console.log(config);

const default_value = {
    userName: '',
    userNick: '',
    logined: false,
    role: [],
    userAccount: '',
    permissions: []
    // userid: '',
    // avatar: '',
    // userGroup: ''
}

const userInfo = {
    state() {
        return {
            userInfo: {
                userName: '',
                userNick: '',
                logined: false,
                role: [],
                userAccount: '',
                permissions: []
                // userid: '',
                // avatar: '',
                // userGroup: ''
            }
        }
    },
    mutations: {
        login(state, loginData) {
            state.userInfo = {
                ...default_value,
                ...loginData,
                logined: true
            };
        },
        logout(state) {
            state.userInfo = {
                ...default_value
            };
        }
    },
    actions: {
        login(context, { data }) {
            context.commit('login', data);
        },
        logout(context) {
            context.commit('logout');
        }
    }
}

export default userInfo;